package com.ciei.dpagm.util;

import java.lang.reflect.Field;
import java.util.Properties;

public class APP {

	public static final String PAGE_SIZE = "pageSize";
	public static final String SORT = "sort";
	public static final String CURRENT_PAGE = "currentPage";
	public static final String PARAMS = "params";
	public static final String DESC = "desc";
	public static final String ASC = "asc";
	public static final String BEFORE = "before";
	public static final String AFTER = "after";

	public static final String AutoSeed = "auto_seed";
	
	public static final String TOTAL_COUNT = "total_count";
	
	public static final String POS = "pos";

	public static final String DATA = "data";

	public static final String ADD = "add";

	public static final String RETURN_DATA = "returnData";

	public static final String TOTAL_NUMBER = "totalNumer";
	
	public static final String ROWS = "rows";
	
	public static final String SUCCESS = "success";

	public final static String MESSAGE = "message";

	public static final String ERROR_CODE = "errorCode";
	
	public static final String MSG = "msg";
	
	public static final String HDFSROOT = "THI";
	
	public static final String DHX_ROW_NUMBER = "rowNumber";
	
	public static final String DHX_ID = "id";
	
	public static final Integer RoleId_CompanyTechnician = 1510;
	
	public static final Integer RoleId_FarmTechnician = 1511;
	
	public static final Integer RoleId_Farmer = 1511;
	
	public static final String GP_UNIT = "gp_unit";
	
	public static final String GP_PERSON = "gp_person";
	
	public static final String GP_ROLE = "gp_role";
	
	public static final String GP_BASIC = "gp_basic";
	
	public static final String GP_PROJECT = "gp_project";
	
	public static final String GP_DATARECORD = "gp_datarecord";
	
	public static final String GP_PROJECT_DATARECORD = "gp_project_datarecord";

	public static final String GP_MODEL = "gp_model";
	
	public static final String SESSION_KEY_CURRENT_USER = "current_user";
	
	public static final String SESSION_KEY_CURRENT_PRODUCT = "current_product";

	public static String RETURN_ORDER_LIST = "returnOrderList";

	static{
		try{
			Properties prop = new Properties();
			prop.load(APP.class.getClassLoader().getResourceAsStream("app.properties"));
			Class c = Class.forName("com.ciei.dpagm.util.APP");
			Field[] fields = c.getDeclaredFields();
			if(fields != null && fields.length > 0){
				for(Field f: fields){
					String propVal = prop.getProperty(f.getName());
					if(propVal == null){
						continue;
					}else{
						Class t = f.getType();
						String p = new String(propVal.getBytes("ISO-8859-1"), "GBK");
						if(t.equals(String.class)){
							f.set(c, p);
						}else if(t.equals(String[].class)){
							f.set(c, p.split(","));
						}else if(t.equals(int.class)){
							f.setInt(c, Integer.parseInt(p));
						}else if(t.equals(Integer.class)){
							f.set(c, new Integer(p));
						}else{
							
						}
					}
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
}
